<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>test</title>
		<script type="text/javascript">
			function check() {
				var emailstr =prompt("请输入正确的邮箱地址", "susan@sohu.com");
				
				if((emailstr.indexOf("@") == -1) || emailstr.indexOf(".") == -1) {
						alert("邮箱中必须包含@和.");
						
					} else if((emailstr.indexOf("@") != -1) && (emailstr.indexOf(".") != -1)&&emailstr.length!=0) {
						var a=emailstr.indexOf("@")
						alert("邮箱地址正确，邮箱名称是："+emailstr.substr(0,a));
					}
					else if(emailstr.length==0){
						alert("邮箱不能为空！");
					}
					else{
						alert("其他错误")
					}
				}
		</script>
	</head>

	<body>
			
		<input type="button" value="点击输入邮箱" onclick="check();" />
	</body>

</html>